﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace Playlist_file_loader.Core
{
    class GuiElements
    {
        //-------------------------------------------------------------------//
        //-------------------------member variables--------------------------//
        //-------------------------------------------------------------------//

        private OpenFileDialog      m_OpenFileDialog;
        private FolderBrowserDialog m_folderBrowserDialog;

        //-------------------------------------------------------------------//
        //-------------------------function definitions----------------------//
        //-------------------------------------------------------------------//



        //-------------------------------------------------------------------//
        // Description: constructor
        public GuiElements()
        {

        }

        //-------------------------------------------------------------------//
        // Description: Shows an OpenFileDialog and returns the Stream to the
        //              choosen file
        // Returns    : Stream - stream to file or null if user hits cancel
        public Stream ShowOpenFileDialog( )
        {
            Stream stream;
            m_OpenFileDialog = new OpenFileDialog();
            Settings.ConfigureOpenFileDialog(m_OpenFileDialog);
            if (m_OpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                if ((stream = m_OpenFileDialog.OpenFile()) != null)
                {
                    return stream;
                }
            }
            return null;
        }

        //-------------------------------------------------------------------//
        // Description: Shows an FolderBrowserDialog and returns the path(String)
        //              to the choosen folder
        // Returns    : String - path to selected folder or null if user hits cancel
        public String ShowOpenFolderBrowserDialog( )
        {
            m_folderBrowserDialog = new FolderBrowserDialog();

            if (m_folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                return m_folderBrowserDialog.SelectedPath;
            }
            return null;
        }

        //-------------------------------------------------------------------//
        // Description: 
        public OpenFileDialog GetOpenFileDialog()
        {
            return m_OpenFileDialog;
        }

        //-------------------------------------------------------------------//
        // Description: 
        public FolderBrowserDialog GetFolderBrowserDialog()
        {
            return m_folderBrowserDialog;
        }

    }
}
